package com.ffcs.crmd.tsp.core.util;
public class ExceptionUtil {
    
    public static String getTraceInfo(Throwable t) {
        StringBuffer buf = new StringBuffer();
        buf.append(createInfo(t));
        return buf.toString();
    }
    
    private static String createInfo(Throwable t) {
        StringBuffer buf = new StringBuffer();
        String s = t.getClass().getName();
        String message = t.getLocalizedMessage();
        buf.append(((message != null) ? (s + ": " + message)
            : s) + "\n");
        StackTraceElement[] elems = t.getStackTrace();
        if (elems != null && elems.length > 0) {
            for (StackTraceElement ele : elems) {
                buf.append(ele.toString() + "\n");
            }
        }
        Throwable c = t.getCause();
        if (c != null) {
            buf.append(createInfo(c));
            buf.append("\n");
        }
        return buf.toString();
    }
}
